package com.bt.lms.service.impl;

import com.bt.lms.entity.TransferInfo;
import com.bt.lms.dao.servise.TransferInfoDao;
import com.bt.lms.dao.servise.impl.TransferInfoDaoImpl;
import com.bt.lms.service.TransferInfoService;

import java.sql.SQLException;

/**
 * 学籍异动实现
 */
public class TransferInfoServiceImpl implements TransferInfoService {
    @Override
    public boolean edit(Long id, TransferInfo transferInfo) throws SQLException {
        StringBuilder editSqlSB = new StringBuilder();
        editSqlSB.append("update transfer_info set")
                .append(" transfer_type = ?,before_state = ?,transfer_cause = ?,later_state = ?")
                .append(",transfer_date = ?,transfer_explain = ?")
                .append(" where id = ? and stu_status_id = ");
        String sql = new String(editSqlSB);

        TransferInfoDao transferInfoDao = new TransferInfoDaoImpl();
        transferInfoDao.update(sql, transferInfo,id);


        return false;
    }

    @Override
    public boolean add(Long id, TransferInfo transferInfo) throws SQLException {
        //维护需要手动设置的东西
        transferInfo.setStuStatusInfoID(id);
        //获取学籍基本信息的id，传过来了
        StringBuilder addSqlSB = new StringBuilder();
        addSqlSB.append("insert into transfer_info(")
                .append("transfer_type,before_state,transfer_cause,later_state,transfer_date,transfer_explain,stu_status_id)")
                .append(" values (?,?,?,?,?,?,?)");
        String sql = new String(addSqlSB);

        TransferInfoDao transferInfoDao = new TransferInfoDaoImpl();
        transferInfoDao.insert(sql, transferInfo);

        return true;
    }

}
